Skip to content

Conversation

sonjh1217
Copy link
Contributor

@sonjh1217 sonjh1217 commented Aug 18, 2025

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@github-actions github-actions bot added the swift label Aug 18, 2025
@sonjh1217 sonjh1217 changed the title best time to buy and sell stock [sonjh1217] week 05 solutions Aug 18, 2025
@sonjh1217 sonjh1217 changed the title [sonjh1217] week 05 solutions [sonjh1217] WEEK05 solutions Aug 18, 2025
@devyejin devyejin self-requested a review August 18, 2025 12:01
Copy link
Contributor

@TonyKim9401 TonyKim9401 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5주차 문제 풀이 진행은 어떠신가요 :)
풀이 중 감이 전혀 안오시거나 하시면 디스코드에 각 문제별 알고리즘 유형을 공유해 두었으니 참고하시면 좋을것 같습니다.
파이팅입니다!

Comment on lines +7 to +8
let profit = prices[i] - minPrice
maxProfit = max(profit, maxProfit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minPrice가 prices[i]보다 큰 경우에만 minPrice를 업데이트 하면 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If minPrice > prices[I] {
minPrice = prices[I]
}

요런 방식이 되겠네요! 사실 그러면 maxProfit = max(profit, maxProfit) 이 부분 역시
if profit > maxProfit {
maxProfit = profit
}

이렇게 될텐데요! 이 변경이 복잡도를 개선하는 것은 아니고, 업데이트를 덜 치기 때문에 약간 더 효율적이지만 min과 max가 주는 가독성이 저는 더 좋게 느껴져서 min, max 방식을 유지하려고 합니다. 디테일한 피드백 넘 감사합니다!

@sonjh1217 sonjh1217 merged commit 809841a into DaleStudy:main Aug 24, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from Solving to Completed in 리트코드 스터디 5기 Aug 24, 2025
@devyejin
Copy link
Contributor

한 주 동안 수고 많으셨습니다. 😄

func groupAnagrams(_ strs: [String]) -> [[String]] {
var stringsByCount = [[Int]: [String]]()

strs.map { str in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map을 사용하셨는데, 반환값을 사용하지 않는 경우라면 forEach를 쓰면 의도가 더 잘 드러날 것 같습니다. 🙂

Copy link
Contributor Author

@sonjh1217 sonjh1217 Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇네요!! 사실 for loop만 많이 쓰다가 될수록 higher-order function을 써보려고 하고 있는데 초보 티가 났네용ㅎㅎ 감사합니다. 다음주 풀리에 반영해서 올릴게요~!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants